package com.ilop.sthome.data.enums;

import com.siterwell.familywellplus.R;

import java.util.Arrays;

/**
 * @author skygge
 * @date 2019/10/24.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：输入输出条件
 */
public enum DeviceTrigger {

    /**
     * 网关
     */
    EE_SIMULATE_GATEWAY(CellsEnum.SMART_GATEWAY, R.array.gateway_actions, R.array.EE_DEV_GATEWAY),

    /**
     * 插座
     */
    EE_DEV_SOCKET(CellsEnum.SMART_SOCKET, R.array.socket_actions,R.array.EE_DEV_SOCKET),

    /**
     * SOS按钮
     */
    EE_DEV_SOS(CellsEnum.SMART_SOS, R.array.sos_actions, R.array.EE_DEV_SOS),

    /**
     * 场景面板
     */
    EE_DEV_MODE_BUTTON(CellsEnum.SMART_SCENE_SWITCH, R.array.mode_button_actions, R.array.EE_DEV_MODE_BUTTON),

    /**
     * PIR探测器（老款）
     */
    EE_DEV_PIR(CellsEnum.SMART_PIR, R.array.pir_actions, R.array.EE_DEV_PIR),

    /**
     * 门磁
     */
    EE_DEV_DOOR1(CellsEnum.SMART_DOOR, R.array.door_actions, R.array.EE_DEV_DOOR),

    /**
     * 按键
     */
    EE_DEV_BUTTON(CellsEnum.SMART_BUTTON, R.array.button_actions, R.array.EE_DEV_BUTTON),

    /**
     * 门锁
     */
    EE_DEV_LOCK(CellsEnum.SMART_DOOR_LOCK, R.array.lock_actions, R.array.EE_DEV_LOCK),

    /**
     * CO报警器
     */
    EE_DEV_CO_ALARM(CellsEnum.SMART_CO_ALARM, R.array.alert_actions, R.array.EE_DEV_ALARM),

    /**
     * SM报警器
     */
    EE_DEV_SM_ALARM(CellsEnum.SMART_SM_ALARM, R.array.alert_actions, R.array.EE_DEV_ALARM),

    /**
     * GAS报警器
     */
    EE_DEV_GAS_ALARM(CellsEnum.SMART_GAS_ALARM, R.array.alert_actions, R.array.EE_DEV_ALARM),

    /**
     * 新GAS报警器
     */
    EE_DEV_NEW_GAS_ALARM(CellsEnum.SMART_NEW_GAS_ALARM, R.array.new_gas_alert_actions, R.array.EE_DEV_NEW_GAS_ALARM),

    /**
     * CO&GAS报警器
     */
    EE_DEV_CO_GAS_ALARM(CellsEnum.SMART_CO_GAS_ALARM, R.array.co_gas_alert_actions, R.array.EE_DEV_CO_GAS_ALARM),

    /**
     * 热感报警器
     */
    EE_DEV_THERM_ALARM(CellsEnum.SMART_THERM_ALARM, R.array.alert_actions, R.array.EE_DEV_ALARM),

    /**
     * 水感报警器
     */
    EE_DEV_WT_ALARM(CellsEnum.SMART_WT_ALARM, R.array.alert_actions, R.array.EE_DEV_ALARM),

    /**
     * 复合型报警器
     */
    EE_DEV_SX_SM_ALARM(CellsEnum.SMART_SX_ALARM, R.array.cx_alert_actions, R.array.EE_DEV_CX_SM_ALARM),

    /**
     * 室外警笛
     */
    EE_TEMP_OUTDOOR_SIREN(CellsEnum.SMART_OUTDOOR, R.array.outdoor_actions, R.array.EE_TEMP_OUTDOOR),

    /**
     * 灯光模块
     */
    EE_DEV_LIGHTING_MODULE(CellsEnum.SMART_LIGHTING_MODULE, R.array.lighting_module, R.array.EE_LIGHTING_MODULE),

    /**
     * 震动闪光报警器
     */
    EE_DEV_FLASH_ALARM(CellsEnum.SMART_FLASH_ALARM, R.array.flash_alarm, R.array.EE_FLASH_ALARM),

    /**
     * 机械手
     */
    EE_DEV_MANIPULATOR(CellsEnum.SMART_MANIPULATOR, R.array.manipulator_valve, R.array.EE_DEV_MANIPULATOR_VALVE),

    /**
     * 电磁阀
     */
    EE_DEV_SOLENOID_VALVE(CellsEnum.SMART_SOLENOID_VALVE, R.array.manipulator_valve, R.array.EE_DEV_MANIPULATOR_VALVE);

    private String[] type;

    private int state;

    private int code;

    DeviceTrigger(String[] type, int state, int code) {
        this.type = type;
        this.state = state;
        this.code = code;
    }

    public String[] getDevType() {
        return type;
    }

    public void setType(String[] type) {
        this.type = type;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public static DeviceTrigger getType(String devType) {
        for (DeviceTrigger deviceTrigger : DeviceTrigger.values()) {
            if (Arrays.asList(deviceTrigger.getDevType()).contains(devType)) {
                return deviceTrigger;
            }
        }
        return null;
    }

}
